how to prevent apps from crashing